//////////////////////////////////////////////////////////////////////////
#pragma once
//////////////////////////////////////////////////////////////////////////
#include <string>
#include <list>
#include <map>
#include "MainHelpers/MainHelpers.h"
//////////////////////////////////////////////////////////////////////////
class CompositeObject
{
public:
	CompositeObject();
	virtual ~CompositeObject();

	virtual void				update(float dt);
	virtual void				render();
	void						setX(const float x);
	void						setY(const float y);
	void						setXY(const float x, const float y) {setX(x); setY(y);};
	void						setAngle(const float angle);
	float						getX() const {return m_x;};
	float						getY() const {return m_y;};
	float						getAngle() const {return m_angle;};
	void						setName(const std::wstring& name) {m_name = name;};
	const std::wstring&			getName() const {return m_name;};
	virtual void				updateTransformationMatrix();
	void						addChild(CompositeObject* child);
	void						removeChild(CompositeObject* child);
	virtual void				setParent(CompositeObject* parent);
	const hlp::Matrix33f&		getTransformationMatrix() const {return m_transformationMatrix;};
	virtual bool				onMouseButtonEvent(int buttonNumber, bool isDown) {return false;};
	void						setVisible(bool visible) {m_visible = visible;};
	bool						getVisible() {return m_visible;};


private:
	void						multiplyTransformationMatrix(const hlp::Matrix33f& matrix);

protected:
	float										m_x;
	float										m_y;
	float										m_angle;
	std::wstring								m_name;
	std::list<CompositeObject*>					m_children;
	CompositeObject*							m_parent;
	std::map<std::wstring, CompositeObject*>	m_namedChildren;
	hlp::Matrix33f								m_transformationMatrix;
	bool										m_visible;
};